﻿using System;
using System.Diagnostics;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using HYView;

namespace YJKArch.PassagewayRamp
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdCreateRampByDoor : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			CmdViewType types = (CmdViewType)123;
			if (SwitchView.SetUsableView(types, cmdData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			if (PassagewayRampDesigner._hWndRevit == null)
			{
				PassagewayRampDesigner._hWndRevit = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			Result result;
			try
			{
				result = new PassagewayRampDesigner(cmdData, null).DesignExtrusionRamp(ref msg);
			}
			catch (Exception ex)
			{
				msg = ex.Message;
				result = Autodesk.Revit.UI.Result.Failed;
			}
			return result;
		}
	}
}
